// 获取元素
let info = document.querySelector('.info')
fetch('http://chst.vip:1234/api/getcoupon')
    .then(body => body.json())
    .then(res => {
        console.log(res.result)

        let el = ''

        res.result.forEach(item => {
            el += `<a href="#" couponid=${item.couponId}>
        <img src=${item.couponImg} alt="">
        <p>${item.couponTitle}</p>
    </a>`
        })

        info.innerHTML = el
    })

$('.info').on('click', 'a', function () {
    // console.log($(this))
    let couponid = $(this).attr('couponid')
    console.log(couponid)
    location.href = `../pages/couponList.html?couponid=${couponid}`
})

// 返回顶部
let toTop = $('.gotop').get(0)
// console.log(toTop)
toTop.onclick = function (e) {
  console.log(123)
  document.documentElement.scrollTop = 0;
}

